package com.xiaolin.designmode.iterator;

/**
 * @ClassName IteratorTest
 * @Description TODO
 * @Detail detail
 * @Author MyPC
 * @Date 2020/11/8
 * @Version 1.0
 */
public class IteratorTest {
    public static void main(String[] args) {
        Aggregate aggregate=new ConcreteAggregate();
        aggregate.add(new Person(1,"小林"));
        aggregate.add(new Person(2,"小北"));
        aggregate.add(new Person(3,"小北"));
        Iterator iterator = aggregate.getIterator();
//        System.out.println(((Person)iterator.first()).getAge());
//        System.out.println(iterator.hasNext());
//        System.out.println(((Person)iterator.next()).getAge());
//        System.out.println(iterator.hasNext());
        while (iterator.hasNext()){
            System.out.println(((Person)iterator.next()).getAge());
        }
    }
}

